﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="MoviePlayer.User_Controls.MovieControls"
    xmlns:custom_ctrl="clr-namespace:MoviePlayer.User_Controls"
    xmlns:SSME="clr-namespace:Microsoft.Web.Media.SmoothStreaming;assembly=Microsoft.Web.Media.SmoothStreaming"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="300">
    <UserControl.Resources>
        <Storyboard x:Name="HideControls" Storyboard.TargetName="ControlPanel">
            <DoubleAnimation x:Name="HideControlAnimation" To="0" Storyboard.TargetProperty="Opacity" Duration="0:0:3"></DoubleAnimation> 
        </Storyboard>
        <Storyboard x:Name="ShowControls" Storyboard.TargetName="ControlPanel">
            <DoubleAnimation x:Name="ShowControlAnimation" To="1" Storyboard.TargetProperty="Opacity" Duration="0:0:1"></DoubleAnimation>
        </Storyboard>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" MouseEnter="LayoutRoot_MouseEnter" MouseLeave="LayoutRoot_MouseLeave">
        <SSME:SmoothStreamingMediaElement x:Name="SSMediaElement" 
                                          Loaded="SSMediaElement_Loaded"
                                          MediaOpened="SSMediaElement_MediaOpened"
                                          MediaEnded="SSMediaElement_MediaEnded"
                                          MediaFailed="SSMediaElement_MediaFailed"
                                          Background="Transparent"
                                          SmoothStreamingSource="{Binding MovieURL}"
                                          AutoPlay="{Binding AutoPlay}" 
                                          HorizontalAlignment="Left"
                                          Width="{Binding Width}"
                                          Stretch="UniformToFill"
                                          LostFocus="SSMediaElement_LostFocus" />
        <Image x:Name="PauseImage" Visibility="{Binding IsPlaying}" Source="/MoviePlayer;component/Resources/Images/biolaselogo.png" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Center" />
        <TextBlock Visibility="{Binding InvalidURL}" VerticalAlignment="Top" HorizontalAlignment="Center" Foreground="Red">Could not open media File.</TextBlock>
        <Grid x:Name="ControlPanel" VerticalAlignment="Bottom" Margin="0,0,0,0" Background="#88175394" Width="{Binding Width, ElementName=SSMediaElement}" MouseEnter="ControlPanel_MouseEnter" MouseLeave="ControlPanel_MouseLeave" Opacity="0.5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="50"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="Button_Play" Grid.Column="0" Height="40" Width="50" VerticalAlignment="Top" Click="Button_Play_Click" HorizontalAlignment="Left" Style="{StaticResource InvisibleButtonStyle}">
                <Path Data="M0,0 L0,100 L50,50" Fill="#FFF4F4F5" Stretch="Fill" Stroke="White" UseLayoutRounding="False" Margin="22,9,18,9"/>
            </Button>
			<Button x:Name="Button_Pause" Grid.Column="0" Width="50" Height="40" VerticalAlignment="Top" Click="Button_Play_Click" HorizontalAlignment="Left" Style="{StaticResource InvisibleButtonStyle}">
				<Path Data="M0,0 L0,100 L20,100 L20,0 L0,0 M30,0 L30,100 L50,100 L50,0" Fill="#FFF4F4F5" Stretch="Fill" Stroke="White" UseLayoutRounding="False" Margin="18,9"/>
			</Button>
            <Slider x:Name="PositionSlider" 
                    Grid.Column="1"
                    Height="20" 
                    VerticalAlignment="Center" 
                    ValueChanged="PositionSlider_ValueChanged" 
                    MouseLeftButtonUp="PositionSlider_MouseLeftButtonUp"
                    Value="{Binding Position.TotalSeconds, ElementName=SSMediaElement, Mode=OneWay}" 
                    Style="{StaticResource InvisibleSliderStyle}" Margin="10,0,10,0"
                    LostFocus="Element_LostFocus" />
			<TextBlock x:Name="PositionText" Grid.Column="2" Margin="10,0,10,0" TextWrapping="NoWrap" Text="0" Foreground="{StaticResource FontBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10"/>
            <Button x:Name="Button_Full_Screen" Grid.Column="3" Click="Button_Full_Screen_Click" Height="40" Width="50" VerticalAlignment="Top" HorizontalAlignment="Left" Style="{StaticResource InvisibleButtonStyle}">
				<Path Data="M0,0 L0,10 L-4,6 L-12,14 L-14,12 L-6,4 L-10,0 L0,0" Fill="#FFF4F4F5" Stretch="Uniform" Stroke="White" UseLayoutRounding="False" Margin="16,7"/>
			</Button>
            <Button x:Name="Button_Exit_Full_Screen" Grid.Column="3" Click="Button_Exit_Full_Screen_Click" Height="40" Width="50" VerticalAlignment="Top" HorizontalAlignment="Left" Style="{StaticResource InvisibleButtonStyle}" Visibility="Collapsed">
                <Path Data="M0,0 L10,0 L6,-4 L14,-12 L12,-14 L4,-6 L0,-10 L0,0" Fill="#FFF4F4F5" Stretch="Uniform" Stroke="White" UseLayoutRounding="False" Margin="16,7"/>
            </Button>
        </Grid>
	</Grid>
</UserControl>
